<template>
	<view class="introduceBox">
		<view class="tab">
			<view class="tab-item" v-for="(item,index) in tabList" :key="index" @click="changeTab(item,index)">
				<view :class="tabActiveIndex==index?'text activeText':'text'">
					{{item.text}}
				</view>
				<view :class="tabActiveIndex==index?'icon activeIcon':'icon'"></view>
			</view>
		</view>
		<view class="tab_one" v-if="tabActiveIndex==0">
			<view class="secondTab">
				<view :class="secondTabActiveIdex==index?'item active':'item'" v-for="(item,index) in secondTab"
					:key="index" @click="changeSecondTab(item,index)">
					{{item.text}}
				</view>
			</view>
			<view class="secondTab_one" v-if="secondTabActiveIdex==0">
				<img src="/static/detail/det1.png" v-for="(item,index) in detailsMsg.images" />
			</view>
			<view class="secondTab_two" v-if="secondTabActiveIdex==1">
			</view>
			<view class="secondTab_three" v-if="secondTabActiveIdex==2">
			</view>
		</view>
		<view class="tab_two" v-if="tabActiveIndex==1">
		</view>
		<view class="tab_three" v-if="tabActiveIndex==2">
		</view>
	</view>
</template>

<script>
	export default {
		props: ["detailsMsg"],
		data() {
			return {
				//tab
				tabList: [{
					id: 1,
					text: "商品详情"
				}, {
					id: 2,
					text: "租享说明"
				}, {
					id: 3,
					text: "常见问题"
				}],
				//tab选中下标
				tabActiveIndex: 1,
				//商品标准tab
				secondTab: [{
					id: 1,
					text: "商品介绍"
				}, {
					id: 2,
					text: "服务标准"
				}, {
					id: 3,
					text: "隐私保障"
				}],
				//商品标准tab选中下标
				secondTabActiveIdex: 0
			}
		},
		methods: {
			//一级菜单切换
			changeTab(item, index) {
				this.tabActiveIndex = index
			},
			//商品详情二级菜单
			changeSecondTab(item, index) {
				this.secondTabActiveIdex = index
			}
		}
	}
</script>

<style lang="scss" scoped>
	.introduceBox {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-bottom: 20rpx;

		.tab {
			width: 95%;
			height: 80rpx;
			margin-top: 30rpx;
			display: flex;
			justify-content: space-around;

			.tab-item {
				width: 150rpx;
				height: 100%;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-between;

				.text {
					font-size: 28rpx;
					color: #4b4b4b;
					font-weight: bold;
				}

				.activeText {
					color: black;
					font-weight: bold;
					font-size: 32rpx;
				}

				.icon {
					width: 50rpx;
					height: 20rpx;
				}

				.activeIcon {
					background-image: url("/static/index/tabActive.png");
					background-size: cover;
				}
			}
		}

		.tab_one {
			width: 95%;

			.secondTab {
				width: 100%;
				height: 100rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.item {
					width: 200rpx;
					height: 70rpx;
					background-color: #F6F6F6;
					text-align: center;
					line-height: 70rpx;
					border-radius: 40rpx;
					font-size: 28rpx;
					color: #666666;
				}

				.active {
					color: black;
					background-color: #FCD748;
				}
			}

			.secondTab_one {
				width: 100%;

				>img {
					width: 100%;
				}
			}
		}
	}
</style>